<template>
  <view class="shareWrap">
    <u-action-sheet
      title="分享"
      round="10"
      :show="shareShow"
      :safeAreaInsetBottom="true"
      :closeOnClickOverlay="true"
      :closeOnClickAction="true"
      @close="shareShow = false"
    >
      <view class="boxSty">
        <view class="shareItem_box">
          <button class="btnClear" open-type="share" title="分销小程序">
            <view class="shareItem">
              <image src="https://res.jiyaqi.com/mall/icon/share01.png"></image>
              <text>微信好友</text>
            </view>
          </button>
          <!-- <button class="btnClear" open-type="share">
            <view class="shareItem">
              <image src="https://res.jiyaqi.com/mall/icon/share02.png"></image>
              <text>朋友圈</text>
            </view>
          </button> -->
          <view class="shareItem" @click="sharePoster">
            <image src="https://res.jiyaqi.com/mall/icon/share03.png"></image>
            <text>分销海报</text>
          </view>
        </view>
        <button
          class="button_box"
          @click="shareShow = false"
          style="border-radius: 32rpx"
        >
          取消
        </button>
      </view>
    </u-action-sheet>
  </view>
</template>

<script>
export default {
  data() {
    return {
      shareShow: false,
      shareList: [
        {
          type: 1,
          icon: 'https://res.jiyaqi.com/mall/icon/share01.png',
          text: '微信',
        },
        {
          type: 2,
          icon: 'https://res.jiyaqi.com/mall/icon/share02.png',
          text: '朋友圈',
        },
        {
          type: 3,
          icon: 'https://res.jiyaqi.com/mall/icon/share03.png',
          text: '海报',
        },
      ],
    }
  },
  props: {
    shareObj: {},
  },
  methods: {
    test(e) {
      console.log(e, 'share------------------')
    },
    handleShare(type) {
      let scene = ''
      if (type == 1) scene = 'WXSceneSession'
      if (type == 2) scene = 'WXSenceTimeline'
      if (type == 1 || type == 2) {
        //分享到微信朋友
        uni.share({
          provider: 'weixin',
          scene: scene,
          type: 0,
          ...this.shareObj,
          success: res => {
            console.log('success:' + JSON.stringify(res))
          },
          fail: err => {
            console.log('fail:' + JSON.stringify(err))
          },
        })
      }
      if (type == 3) {
        uni.share({
          provider: 'qq',
          type: 0,
          ...this.shareObj,
          success: res => {
            console.log('success:' + JSON.stringify(res))
          },
          fail: err => {
            console.log('fail:' + JSON.stringify(err))
          },
        })
      }
    },
    // 分享海报
    sharePoster() {
      this.shareShow = false
      this.$emit('sharePoster')
    },
  },
}
</script>

<style lang="scss">
.boxSty {
  padding: 0rpx 32rpx 48rpx;
}
::v-deep .u-action-sheet__header {
  padding: 0;
  margin-top: 48rpx;
}
::v-deep .u-action-sheet__header__icon-wrap {
  right: 32rpx;
  top: 0;
}
.shareWrap {
  .shareItem_box {
    margin: 80rpx auto;
    display: flex;
    justify-content: space-around;
    .shareItem {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: space-between;
      image {
        width: 96rpx;
        height: 96rpx;
      }
      text {
        margin-top: 20rpx;
        font-size: 28rpx;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #1a1a1a;
        line-height: 28rpx;
      }
    }
  }
  .button_box {
    margin: 0 auto;
    width: 686rpx;
    height: 80rpx;
    background: #f5f5f5;
    border: none;
    border-radius: 40rpx;
    font-size: 32rpx;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 500;
    color: #666666;
  }
  .btnClear {
    margin: 0;
    padding: 0;
    background-color: transparent;
    font-size: 28rpx;
  }
  ::v-deep .u-action-sheet {
    background-color: #ffffff;
    border-top-left-radius: 20rpx;
    border-top-right-radius: 20rpx;
  }
}
</style>
